package com.xuan.yubi.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xuan.yubi.model.dto.chart.ChartQueryRequest;
import com.xuan.yubi.model.dto.chart.GenChartByAiRequest;
import com.xuan.yubi.model.entity.Chart;
import com.baomidou.mybatisplus.extension.service.IService;
import com.xuan.yubi.model.vo.BiResponse;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

/**
* @author 清凉茶
* @description 针对表【chart(图表表)】的数据库操作Service
* @createDate 2024-05-30 14:27:09
*/
public interface ChartService extends IService<Chart> {

    /**
     * 新增图表记录
     * @param chart
     * @param add
     */
    void validChart(Chart chart, boolean add);

    /**
     *  组装查询信息
     * @param chartQueryRequest
     * @return
     */
    Wrapper<Chart> getQueryWrapper(ChartQueryRequest chartQueryRequest);

    /**
     *  genChart解析错误，修改图表状态
     * @param id
     * @param userId
     * @param isAdmin
     * @return
     */
    boolean updateStatusByParseError(Long id, Long userId, boolean isAdmin);

    /**
     *  根据 图表id 获取图表数据
     * @param chartId
     * @param userId
     * @param isAdmin
     * @return
     */
    Chart getChartVoById(long chartId, Long userId, boolean isAdmin);

    /**
     *  删除图表
     * @param chartId
     * @param userId
     * @param isAdmin
     * @return
     */
    boolean deleteChart(long chartId, Long userId, boolean isAdmin);

    /**
     *  分页获取当前用户分析的图表
     * @param chartQueryRequest
     * @return
     */
    Page<Chart> listMyChartVOByPage(ChartQueryRequest chartQueryRequest);

    /**
     *  同步生成分析图表
     * @param multipartFile
     * @param genChartByAiRequest
     * @param userId
     * @return
     */
    BiResponse genChartByAiSync(MultipartFile multipartFile, GenChartByAiRequest genChartByAiRequest, Long userId);

    /**
     *  使用线程池异步生成图表
     * @param multipartFile
     * @param genChartByAiRequest
     * @param userId
     * @return
     */
    BiResponse genChartByAiAsync(MultipartFile multipartFile, GenChartByAiRequest genChartByAiRequest, Long userId);

    /**
     *  使用消息队列异步生成图表
     * @param multipartFile
     * @param genChartByAiRequest
     * @param userId
     * @return
     */
    BiResponse genChartByAiAsyncMq(MultipartFile multipartFile, GenChartByAiRequest genChartByAiRequest, Long userId);

    boolean retryGen(Long chartId, Long userId);
}
